package com.zzedu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzedu.domain.ZzStudent;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 学生信息Mapper接口
 * @author Mr.Wang
 * @date 2025-02-16
 */
public interface ZzStudentMapper extends BaseMapper<ZzStudent>
{

    @Select("<script>" +
            "SELECT school_id , COUNT(*) AS student_count " +
            "FROM zz_student " +
            "WHERE deleted = 0 " +
            "<if test='schoolIds != null and schoolIds.size() > 0'> " +
            "AND school_id IN " +
            "<foreach item='id' collection='schoolIds' open='(' separator=',' close=')'> " +
            "#{id} " +
            "</foreach> " +
            "</if> " +
            "GROUP BY school_id " +
            "</script>")
    List<Map<String, Object>> countStudentsBySchool(@Param("schoolIds") List<Long> schoolIds);
}
